<template>
  <div class="table-search-page">
    <div class="g-tabs-wrapper">
      <a-tabs :activeKey="currentActiveKey" @change="changeTabs" type="line">
        <a-tab-pane :key="1" tab="预约登记"></a-tab-pane>
        <a-tab-pane :key="2" tab="客户复查"></a-tab-pane>
        <!-- <a-tab-pane :key="3" tab="预约审批"></a-tab-pane> -->
        <!-- <a-tab-pane :key="2" tab="客户指派列表"></a-tab-pane>
        <a-tab-pane :key="3" tab="已划扣项目客户列表"></a-tab-pane> -->
      </a-tabs>
    </div>
    <a-card class="g-mt-10" :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline" :form="form" :selfUpdate="true">
          <a-row :gutter="12">
            <a-col :md="12" :lg="6" :sm="12" style="padding: 0 4px">
              <a-form-item label="治疗时间">
                <a-range-picker :allowClear="true" v-decorator="['time']" 
                  style="width: 100%" 
                  @change="timeDateChange"
                >
                  <a-icon slot="suffixIcon" type="calendar" />
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col :md="1" :lg="1" :sm="12" style="padding: 0 4px"> </a-col>
            <a-col :md="12" :lg="5" :sm="12" style="padding: 0 4px">
              <a-form-item label="名称">
                <a-input v-decorator="['clientName']" allow-clear placeholder="请输入客户卡号或名称" />
              </a-form-item>
            </a-col>
            <!-- <a-col :md="12" :lg="5" :sm="12" style="padding: 0 4px;">
              <a-form-item label="联系号码">
                <a-input v-decorator="['mobile']" allow-clear placeholder="联系号码"/>
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="4" :sm="12" style="padding: 0 4px;">
              <a-form-item label="客户姓名">
                <a-input v-decorator="['name']" style="width: 100%" allow-clear placeholder="姓名"/>
              </a-form-item>
            </a-col> -->
            <a-col :md="2" :lg="4" :sm="12">
              <div class="table-page-search-submitButtons g-flex" style="margin-bottom: 4px">
                <!-- <a-icon :type="advanced ? 'up' : 'down'" @click="advanced=!advanced" style="margin-right: 15px;"/> -->
                <a-button type="primary" @click="clickSearch">查询</a-button>
                <a-button style="margin-left: 8px" @click="clickReset">重置</a-button>
              </div>
            </a-col>
          </a-row>
          <!-- <a-row :gutter="12" v-show="advanced">
            <a-col :md="12" :lg="6" :sm="12" style="padding: 0 4px;">
              <a-form-item label="开发人员">
                <a-select
                  @search="select_search_developer"
                  :showSearch="true"
                  option-filter-prop="children"
                  allow-clear
                  option-label-prop="label"
                  style="width: 100%"
                  v-decorator="['developer']"
                  placeholder="选择，搜索">
                  <a-select-option v-for="item in allHisUser.userList" :key="item.id" :label="item.name" :value="item.id">{{ item.name }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="5" :sm="12" style="padding: 0 4px;">
              <a-form-item label="所属咨询">
                <a-select
                  @search="select_search_consultMan"
                  :showSearch="true"
                  option-filter-prop="children"
                  allow-clear
                  option-label-prop="label"
                  style="width: 100%"
                  v-decorator="['consultMan']"
                  placeholder="选择，搜索">
                  <a-select-option v-for="item in allHisUser.userList" :key="item.id" :label="item.name" :value="item.id">{{ item.name }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="5" :sm="12" style="padding: 0 4px;">
              <a-form-item label="客户等级">
                <a-select
                  allow-clear
                  option-label-prop="label"
                  style="width: 100%"
                  v-decorator="['customerLevel']"
                  placeholder="客户等级">
                  <a-select-option v-for="item in customerLevel" :key="item.id" :label="item.name" :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="4" :sm="12" style="padding: 0 4px;">
              <a-form-item label="客户状态">
                <a-select
                  allow-clear
                  option-label-prop="label"
                  style="width: 100%"
                  v-decorator="['customerState']"
                  placeholder="状态">
                  <a-select-option v-for="item in customerState" :key="item.id" :label="item.name" :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </a-row> -->
        </a-form>
      </div>
    </a-card>

    <a-card :bordered="false">
      <div style="position: relative">
        <a-button
          type="primary"
          icon="plus-circle" 
          @click="$refs.addCustomer.add(currentActiveKey)"
          >新增</a-button
        >
        <a-tabs
          v-if="currentActiveKey != 2"
          :activeKey="currentActiveKey2"
          @change="changeTabs2"
          type="line" 
        >
          <a-tab-pane :key="1" tab="前台登记">
            <super-table
              :scroll="{ x: 1000 }"
              ref="table"
              :rowKey="(record, index) => index"
              :columns="columns"
              :data="loadData"
            >
              <!--序号-->
              <template slot="index" slot-scope="text, record, index">
                <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
              </template>
              <!--客户卡号-->
              <!-- <template slot="cardNo" slot-scope="text, record">
                <div class="g-color g-f-14" style="cursor: pointer" @click="toCustomerDetails(text, record)">
                  {{ text }}
                </div>
              </template> -->
              <template slot="action" slot-scope="text, record">
                <div class="g-flex" v-if="currentActiveKey == 1">
                  <a-button class="btn-class-no-border" type="link" @click="endTreat(record)">治疗开单</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="endTreatHistory(record)">开单记录</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
                </div>
                <div class="g-flex" v-if="currentActiveKey == 2">
                  <a-button class="btn-class-no-border" type="link" @click="recheckBilling(record)">复查开单</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="recheckBillingHistory(record)"
                    >开单记录</a-button
                  >
                  <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
                </div>

                <!-- <div class="g-flex" v-if="currentActiveKey==3">
                  <a-button type="link">项目详情</a-button>
                  <a-button type="link">指派</a-button>
                  
                </div> -->
              </template>
              
            </super-table>
          </a-tab-pane>
          <a-tab-pane :key="3" tab="预约审批">
            <super-table
              :scroll="{ x: 1000 }"
              ref="table2"
              :rowKey="(record, index) => index"
              :columns="columns3"
              :data="loadData"
            >
              <!--序号-->
              <template slot="index" slot-scope="text, record, index">
                <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
              </template>
              <!--客户卡号-->
              <!-- <template slot="cardNo" slot-scope="text, record">
                <div class="g-color g-f-14" style="cursor: pointer" @click="toCustomerDetails(text, record)">
                  {{ text }}
                </div>
              </template> -->
              <template slot="action" slot-scope="text, record">
                <div class="g-flex" v-if="currentActiveKey == 1">
                  <a-button class="btn-class-no-border" type="link" @click="endTreat(record)">治疗开单</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="endTreatHistory(record)">开单记录</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
                </div>
                <div class="g-flex" v-if="currentActiveKey == 2">
                  <a-button class="btn-class-no-border" type="link" @click="recheckBilling(record)">复查开单</a-button>
                  <a-button class="btn-class-no-border" type="link" @click="recheckBillingHistory(record)"
                    >开单记录</a-button
                  >
                  <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
                </div>

                <!-- <div class="g-flex" v-if="currentActiveKey==3">
                  <a-button type="link">项目详情</a-button>
                  <a-button type="link">指派</a-button>
                  
                </div> -->
              </template>
              <!-- 预约审核 -->
              <!-- 状态 -->
              <span slot="status" slot-scope="text">
                <a-tag :color="text == '待审核' ? '#39f' : 'green'">
                  {{ text }}
                </a-tag>
              </span>

              <!-- 项目 -->
              <template slot="treatmentName" slot-scope="text">
                <div v-html="text" style="text-align: left">{{ text }}</div>
              </template>
              <template slot="action2" slot-scope="text, record">
                <div style="margin: 0 auto">
                  <!-- <a-button class="not-border-btn-style" style="padding: 0" type="link" @click="examineApprove(record)"
                    >审批</a-button > -->
                  <a-popconfirm title="是否确认审批?" @confirm="() => examineApprove(record)" style="margin-right:10px">
                    <a>审批</a>
                  </a-popconfirm>
                  <a-popconfirm title="作废该项数据?" @confirm="() => examineApprovehandRemove(record)">
                    <a>作废</a>
                  </a-popconfirm>
                </div>
              </template>
              <!-- 预约审核end -->
            </super-table>
          </a-tab-pane>
        </a-tabs>

        <super-table
          v-if="currentActiveKey == 2"
          :scroll="{ x: 1000 }"
          ref="table3"
          :rowKey="(record, index) => index"
          :columns="currentActiveKey === 3 ? columns3 : columns"
          :data="loadData"
        >
          <!--序号-->
          <template slot="index" slot-scope="text, record, index">
            <span>{{ (queryParam.pageNum - 1) * queryParam.pageSize + (index + 1) }}</span>
          </template>
          <!--客户卡号-->
          <!-- <template slot="cardNo" slot-scope="text, record">
            <div class="g-color g-f-14" style="cursor: pointer" @click="toCustomerDetails(text, record)">
              {{ text }}
            </div>
          </template> -->
          <template slot="action" slot-scope="text, record">
            <div class="g-flex" v-if="currentActiveKey == 1">
              <a-button class="btn-class-no-border" type="link" @click="endTreat(record)">治疗开单</a-button>
              <a-button class="btn-class-no-border" type="link" @click="endTreatHistory(record)">开单记录</a-button>
              <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
            </div>
            <div class="g-flex" v-if="currentActiveKey == 2">
              <a-button class="btn-class-no-border" type="link" @click="recheckBilling(record)">复查开单</a-button>
              <a-button class="btn-class-no-border" type="link" @click="recheckBillingHistory(record)"
                >开单记录</a-button
              >
              <a-button class="btn-class-no-border" type="link" @click="handRemove(record)">作废</a-button>
            </div>

     
          </template>
        
        </super-table>
      </div>
    </a-card>

    <!--新增客户--弹窗-->
    <add-customer ref="addCustomer" @addOk="addOk()" />
    <!--复查开单--弹窗-->
    <recheck-billing ref="recheckBilling" :row_record="current_row_record" />

    <!-- 治疗开单弹出 -->
    <reception-dawer ref="receptionDawer" :row_record="current_row_record" />

    <!-- 开单记录 -->
    <history-dawer ref="historyDawer" :row_record="current_row_record"></history-dawer>
  </div>
</template>

<script>
import { AllHisUser, CustomerLevel, CustomerState } from '@/api/customer/customer'
import { CustomerFeedback } from '@/api/modular/main/customer/customerReturnVisit'
import { 
  returnOrder,
  Reception, 
  DeleteDeductedList, 
  AddMakeScheduleTgsTreat
} from '@/api/modular/main/customer/cashier'
import { 
  UpdateScheduler,
  GetScheduleList,
  KillSchedule,
  
 } from '@/api/modular/main/bookingManagement/bookingManagement'
import { SuperTable } from '@/components'
import moment from 'moment'
import addCustomer from '@/views/departmentReception/reception/addCustomer'
import recheckBilling from '@/views/departmentReception/reception/recheckBilling'
import receptionDawer from '@/views/departmentReception/reception/receptiondDawer'
import historyDawer from '@/views/departmentReception/reception/historyDawer'
export default {
  components: {
    SuperTable,
    addCustomer,
    recheckBilling,
    receptionDawer,
    historyDawer,
  },
  data() {
    return {
      loadData: (parameter) => {
        this.queryParam.pageNum = parameter ? parameter.pageNum : 1
        this.queryParam.pageSize = parameter ? parameter.pageSize : 10
        console.log(parameter)
        console.log(this.queryParam)
        return Reception(this.queryParam).then((res) => {
          this.loading = false //关闭加载
          return res
        })
      },
      form: this.$form.createForm(this),
      customerState: [], //客户状态
      customerLevel: [], //客户等级
      advanced: false, // 高级搜索 展开/关闭
      disabled: true, //是否禁用新增按钮
      current_row_record: {},
      columns: [
        { title: '序号', scopedSlots: { customRender: 'index' }, align: 'center', width: 80, fixed: 'left' },
        {
          title: '客户卡号',
          dataIndex: 'cardNo',
          width: 120,
          align: 'center',
          // scopedSlots: { customRender: 'cardNo' },
          ellipsis: true,
        },
        { title: '客户姓名', dataIndex: 'clientName', width: 100, align: 'center', ellipsis: true },
        { title: '科室', dataIndex: 'deptName', width: 100, align: 'center', ellipsis: true },
        {
          title: '就诊状态',
          dataIndex: 'admissionStateName',
          width: 100,
          align: 'center',
          ellipsis: true,
          // scopedSlots: { customRender: 'admissionStateName'},
        },
        // { title: '当前状态', dataIndex: 'currentStateName', width: 100, align:'center', ellipsis: true },
        { title: '接待人', dataIndex: 'receiveMan', width: 120, align: 'center', ellipsis: true },
        { title: '接待时间', dataIndex: 'receiveDate', width: 180, align: 'center', ellipsis: true },
        { title: '操作', scopedSlots: { customRender: 'action' }, fixed: 'right', width: 180, align: 'center' },
      ],
      columns2: [
        { title: '序号', scopedSlots: { customRender: 'index' }, align: 'center', width: 80, fixed: 'left' },
        { title: '科室', dataIndex: 'deptName', width: 120, align: 'center', ellipsis: true },
        { title: '客户卡号', dataIndex: 'cardNo', width: 100, align: 'center', ellipsis: true },
        { title: '姓名', dataIndex: 'name', width: 100, align: 'center', ellipsis: true },
        { title: '状态', dataIndex: 'state', width: 100, align: 'center', ellipsis: true },
        { title: '叫号号码', dataIndex: 'callNo', width: 100, align: 'center', ellipsis: true },
        { title: '指派会诊医生', dataIndex: 'treatDrName', width: 150, align: 'center', ellipsis: true },
        { title: '指派时间', dataIndex: 'receiveDate', width: 180, align: 'center', ellipsis: true },
        { title: '操作', scopedSlots: { customRender: 'action' }, fixed: 'right', width: 180, align: 'center' },
      ],
      columns3: [
        { title: '序号', scopedSlots: { customRender: 'index' }, align: 'center', width: 80, fixed: 'left' },
        {
          title: '顾客卡号',
          align: 'center',
          dataIndex: 'cardNo',
          // scopedSlots: { customRender: 'cardNo' },
          width: 140,
          ellipsis: true,
        },
        { title: '顾客姓名', align: 'center', dataIndex: 'customerName', width: 140, ellipsis: true },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' },
          width: 140,
          ellipsis: true,
        },
        { title: '预约时间', align: 'center', dataIndex: 'scheduleDate', width: 140, ellipsis: true },
        { title: '提交人', align: 'center', dataIndex: 'creator', width: 140, ellipsis: true },
        { title: '提交时间', align: 'center', dataIndex: 'createTime', width: 140, ellipsis: true },

        {
          title: '预约项目',
          align: 'center',
          scopedSlots: { customRender: 'treatmentName' },
          dataIndex: 'treatmentName',
          width: 200,
        },
        { title: '预约医生', align: 'center', dataIndex: 'expertName', width: 140, ellipsis: true },
        { title: '所属客管', align: 'center', dataIndex: 'zxName', width: 140, ellipsis: true },
        { title: '麻醉类型', align: 'center', dataIndex: 'hoCusSel', width: 140, ellipsis: true },
        { title: '检查结果', align: 'center', dataIndex: 'isCheck', width: 140, ellipsis: true },
        { title: '费用情况', align: 'center', dataIndex: 'isMoney', width: 140, ellipsis: true },
        { title: '备注', align: 'center', dataIndex: 'memo', width: 140, ellipsis: true },
        {
          title: '操作',
          align: 'center',
          scopedSlots: { customRender: 'action2' },
          align: 'center',
          width: 120,
          fixed: 'right',
        },
      ],

      data: [],
      pagination: {
        current: 1, //当前页
        pageSize: 10, //当前页数
        total: 0, //总条数
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: ['10', '20', '30'], //这里注意只能是字符串，不能是数字
        showTotal: (total) => `共有 ${total} 条数据`, //分页中显示总的数据
      },
      // 查询参数
      queryParam: {
        pageNum: 1, //第几页
        pageSize: 10, //每页中显示数据的条数
        type: 1,
        startTime: undefined,
        endTime: undefined,
        chargeType: 1,
        currentState: 0, // 未指派
      },
      loading: true, //加载状态,
      current_row_index: '',
      customerFeedback: {},
      allHisUser: {}, //回访人对象
      currentActiveKey: 1,
      currentActiveKey2: 1,
    }
  },
  created() {
    this.getBaseFormInfo()
  },
  methods: {
    timeDateChange(val){ 
      if(val.length < 1){
        this.queryParam.startTime = undefined
        this.queryParam.endTime = undefined
        this.form.setFieldsValue({
          time: [],
        })
      } 
      
    },
    // 预约审批
    examineApprove(record) {
      console.log('审批:', record)
      let sendData = {
        id: record.tbSchedulerId,
        reportType: record.reportType
      }
      UpdateScheduler(sendData).then((res) => {
        if (res.code == 200) {
          this.$message.success(res.message)
          AddMakeScheduleTgsTreat(sendData).then(result => {
            if(result.code == 200){ 
              this.$refs.table2.loadData() 
            }else{
              this.$message.error(result.message)
            }
          })
          
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // 预约作废
    examineApprovehandRemove(record) {
      console.log(record)
      let sendData = {
        schedulerReportId: record.tbSchedulerId,
        clientId: record.customerId,
        type: record.reportType == '到院' ? 1:''
      }
      KillSchedule(sendData).then((res) => {
        if (res.code == 200) {
          this.$message.success(res.data) 
          this.$refs.table2.loadData() 
        } else {
          this.$message.error(res.message)
        }
      })
    },
    addOk() {
      console.log('触发啊')
       
      if(this.currentActiveKey == '2'){
        this.$refs.table3.loadData()
      }
      if(this.currentActiveKey2 == '1'){
        this.$refs.table.loadData()
      }else if(this.currentActiveKey2 == '3'){
        this.$refs.table2.loadData()
      }
      
      
      
    },
    checkPattern(str) {
      const pattern = new RegExp('[\u4E00-\u9FA5]+')
      if (pattern.test(str)) {
        return true
      }
      return false
    },
    //下拉框搜索查找
    select_search_consultMan(value) {
      this.form.setFieldsValue({
        consultMan: value,
      })
    },
    //下拉框搜索查找
    select_search_developer(value) {
      this.form.setFieldsValue({
        developer: value,
      })
    },

    moment,
    toCountDown(time) {
      //1000代表1秒，1000*60代表60分钟
      return Date.now() + parseInt(time) * 1000
    },
    minutesToSeconds(time) {
      return parseInt(time)
    },
    
    //点击查询-高级搜索
    clickSearch() {
      const form_values = this.form.getFieldsValue()
      const time = form_values.time
      this.queryParam.pageNum = 1
      this.queryParam.pageSize = 10
      this.queryParam.current = 1

      if (time && time.length > 0) {
        form_values.startTime = moment(time[0]).format('YYYY-MM-DD')
        form_values.endTime = moment(time[1]).format('YYYY-MM-DD')
        form_values.time = undefined
      }

      if (form_values.clientName) {
        form_values.clientName = form_values.clientName.replace(/\s*/g, '')
      }

      this.queryParam = Object.assign(this.queryParam, form_values)
      if(this.currentActiveKey == '2'){
        this.$refs.table3.loadData()
      }
      if(this.currentActiveKey2 == '1'){
        this.$refs.table.loadData()
      }else if(this.currentActiveKey2 == '3'){
        this.$refs.table2.loadData()
      }
    },
    clickReset() {
      this.form.resetFields()
      const form_values = this.form.getFieldsValue()
      form_values.startTime = undefined
      form_values.endTime = undefined
      this.queryParam = Object.assign(this.queryParam, form_values)
    },
    recheckBilling(record) {
      this.current_row_record = record

      this.$nextTick(() => {
        this.$refs.recheckBilling.show()
      })
    },

    
    endTreat(record) {
      // let _this =this
      this.current_row_record = record
      this.$refs.receptionDawer.show()
      // this.$confirm({
      //   title: '确认完成治疗吗？',
      //   content: h => <div style="color:red;">确认完成治疗吗？</div>,
      //   onOk() {
      //     const orderId=record.orderId
      //     returnOrder({orderId}).then(res=>{
      //       if(res.code==200){
      //         _this.$message.success('退回成功')
      //         _this.$refs.table.refresh()
      //       }else{
      //         _this.$message.info(res.message)
      //       }
      //     })
      //   },
      //   class: 'test',
      // })
    },

    changeTabs(key) {
      this.currentActiveKey = key
      this.currentActiveKey2 = 1

      if (key == 1) {
        this.queryParam.currentState = 0
        this.queryParam.chargeType = 1
        this.queryParam.type = 1
        this.loadData = (parameter) => {
          this.queryParam.pageNum = parameter ? parameter.pageNum : 1
          this.queryParam.pageSize = parameter ? parameter.pageSize : 10
          return Reception(this.queryParam).then((res) => {
            this.loading = false //关闭加载
            let newData = Object.assign({}, res)
            return newData
          })
        }
        this.$nextTick(() => { 
          this.$refs.table.loadData()
        })
      }else if (key == 2) {
        this.queryParam.currentState = 1
        this.queryParam.chargeType = 1
        this.queryParam.type = 2
        this.loadData = (parameter) => {
          this.queryParam.pageNum = parameter ? parameter.pageNum : 1
          this.queryParam.pageSize = parameter ? parameter.pageSize : 10
          return Reception(this.queryParam).then((res) => {
            this.loading = false //关闭加载
            let newData = Object.assign({}, res)
            return newData
          })
        }
        this.$nextTick(() => { 
          this.$refs.table3.loadData()
        })
      } else if (key == 3) {
        // this.queryParam.reportType = 2
        this.queryParam.type = 2
        this.loadData = (parameter) => {
          this.queryParam.pageNum = parameter ? parameter.pageNum : 1
          this.queryParam.pageSize = parameter ? parameter.pageSize : 10
          
          return GetScheduleList(this.queryParam).then((res) => {
            this.loading = false //关闭加载
            res.rows.map(item => {
              item.treatmentName = item.reportType == '手术'?item.treatmentName:item.treatmentName1
            })
            let newData = Object.assign({}, res)
            return newData
          })
        }
        this.$nextTick(() => { 
          this.$refs.table2.loadData()
        })
      }

      
    },
    changeTabs2(key) {
      this.currentActiveKey2 = key

      if (key == 1) {
        this.queryParam.currentState = 0
        this.queryParam.chargeType = 1
        this.queryParam.type = 1
        this.loadData = (parameter) => {
          this.queryParam.pageNum = parameter ? parameter.pageNum : 1
          this.queryParam.pageSize = parameter ? parameter.pageSize : 10
          return Reception(this.queryParam).then((res) => {
            this.loading = false //关闭加载
            let newData = Object.assign({}, res)
            return newData
          })
        }
        this.$nextTick(() => { 
          this.$refs.table.loadData()
        })
      } else if (key == 3) {
        // this.queryParam.reportType = 2
        this.queryParam.type = 2
        this.loadData = (parameter) => {
          this.queryParam.pageNum = parameter ? parameter.pageNum : 1
          this.queryParam.pageSize = parameter ? parameter.pageSize : 10
          return GetScheduleList(this.queryParam).then((res) => {
            this.loading = false //关闭加载
            res.rows.map(item => {
              item.treatmentName = item.reportType == '手术'?item.treatmentName:item.treatmentName1
            })
            let newData = Object.assign({}, res)
            return newData
          })
        }
        this.$nextTick(() => { 
          this.$refs.table2.loadData()
        })
      }

       
    },
    //点击查看客户详情
    toCustomerDetails(text, record) {
      // console.log(record)
      this.$router.push({
        path: 'customer_details',
        query: {
          id: record.customerId,
          card_no: record.cardNo,
          customerName:record.customerName
        },
      })
    },

    //获取表单相关接口
    getBaseFormInfo() {
      CustomerFeedback().then((res) => {
        // console.log('回访相关表单接口',res)
        this.customerFeedback = res
      })
      AllHisUser().then((res) => {
        this.allHisUser = res
      })
      CustomerLevel().then((res) => {
        this.customerLevel = res
      })
      CustomerState().then((res) => {
        this.customerState = res
      })
    },

    // 客户复查--开单记录点击事件
    recheckBillingHistory(record) {
      this.current_row_record = record
      this.$refs.historyDawer.show(1)
    },

    // 前台登记--开单记录点击事件
    endTreatHistory(record) {
      this.current_row_record = record
      this.$refs.historyDawer.show(2)
    },

    // 移除
    handRemove(record) {
      let that = this
      console.log(record)
      let sendData = {
        receiveId: record.receiveId,
      }
      this.$confirm({
        title: '提示',
        content: (h) => <div style="color:red;">确认作废这条记录？</div>,
        onOk() {
          DeleteDeductedList(sendData).then((res) => {
            console.log(res)
            if (res.code == 200) {
              
              if(that.currentActiveKey == '2'){
                that.$refs.table3.loadData()
              }
              if(that.currentActiveKey2 == '1'){
                that.$refs.table.loadData()
              }else if(that.currentActiveKey2 == '3'){
                that.$refs.table2.loadData()
              }
              that.$message.success(res.message)
            } else {
              that.$message.error(res.message)
            }
          })
        },
        class: 'test',
      })
    },
  },
}
</script>

<style lang="less" scoped>
.table-operator {
  margin-bottom: 18px;
}

button {
  margin-right: 8px;
  margin-bottom: 2px;
}

.currentRowClass {
  background: #e6f7ff;
}

/deep/ .ant-tabs-bar {
  border-bottom: none;
}

/deep/ .ant-badge-count,
.ant-badge-dot,
.ant-badge .ant-scroll-number-custom-component {
  right: -10px;
}
/deep/ .btn-class-no-border {
  border-color: transparent !important;
  padding: 0;
  color: #5badff;
  font-size: 13px;
}
/deep/ .not-border-btn-style,
/deep/ .not-border-btn-style:hover {
  border: 0;
  border-color: rgba(255, 255, 255, 0) !important;
}
 
</style>